package com.mongodb.pojo;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.util.Date;

/**
 * @author xiaochi
 * @date 2022/3/17 10:21
 * @desc UserPojo
 */
@Data
@Document("User")
public class UserPojo {

    // @MongoId 也可以
    @Field("id")
    @Id
    private String id;

    @Indexed(unique = true) // 唯一索引
    private String name;

    @Indexed // 普通索引
    private Integer age;

    @Field("create_time")
    private Date createDate;
}
